package com.lrs.java.j2se_self.gui;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class TestMouseAdapter {
	public static void main(String[] args){
		new MyFrame("MyMouseAdapter");
	}
}
class MyFrame extends Frame {
	ArrayList<Point> points = null ;
	MyFrame (String s){
		super(s);
		points = new ArrayList<Point>();
		this.setBounds(100,200,300,400);
		this.setBackground(new Color(100,200,150));
		this.setLayout(null);
		this.setVisible(true);
		this.addMouseListener(new Monitor());
	}
	public void addPoint(Point p){
		points.add(p);
		
	}
	public void paint (Graphics g){
		Color c = g.getColor();
		g.setColor(Color.red);
		Iterator<Point> i = points.iterator();
		while(i.hasNext()){
			Point p = i.next();
			//Point p = (Point)i.next();		
			g.fillOval(p.x, p.y, 10, 10);
		}
	}
	private class Monitor extends MouseAdapter {
		public void mousePressed (MouseEvent m) {
			MyFrame mf = (MyFrame)m.getSource();
			mf.addPoint(m.getPoint());
			mf.repaint();
		}
	}
}
